package vip.xiaonuo.supplier.modular.custom.customtype.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.supplier.modular.custom.customtype.entity.SupplierCustomType;
import vip.xiaonuo.supplier.modular.custom.customtype.param.SupplierCustomTypeAddParam;
import vip.xiaonuo.supplier.modular.custom.customtype.param.SupplierCustomTypeEditParam;
import vip.xiaonuo.supplier.modular.custom.customtype.param.SupplierCustomTypeIdParam;
import vip.xiaonuo.supplier.modular.custom.customtype.param.SupplierCustomTypePageParam;
import vip.xiaonuo.supplier.modular.custom.customtype.service.SupplierCustomTypeService;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 客户类型控制器
 *
 * @author Mr.wu
 * @date  2025/03/15 17:38
 */
@Tag(name = "客户类型控制器")
@RestController
@Validated
public class SupplierCustomTypeController {

    @Resource
    private SupplierCustomTypeService supplierCustomTypeService;

    /**
     * 获取客户类型分页
     *
     * @author Mr.wu
     * @date  2025/03/15 17:38
     */
    @Operation(summary = "获取客户类型分页")
    @SaCheckPermission("/supplier/custom/customtype/page")
    @GetMapping("/supplier/custom/customtype/page")
    public CommonResult<Page<SupplierCustomType>> page(SupplierCustomTypePageParam supplierCustomTypePageParam) {
        return CommonResult.data(supplierCustomTypeService.page(supplierCustomTypePageParam));
    }

    /**
     * 添加客户类型
     *
     * @author Mr.wu
     * @date  2025/03/15 17:38
     */
    @Operation(summary = "添加客户类型")
    @CommonLog("添加客户类型")
    @SaCheckPermission("/supplier/custom/customtype/add")
    @PostMapping("/supplier/custom/customtype/add")
    public CommonResult<String> add(@RequestBody @Valid SupplierCustomTypeAddParam supplierCustomTypeAddParam) {
        supplierCustomTypeService.add(supplierCustomTypeAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑客户类型
     *
     * @author Mr.wu
     * @date  2025/03/15 17:38
     */
    @Operation(summary = "编辑客户类型")
    @CommonLog("编辑客户类型")
    @SaCheckPermission("/supplier/custom/customtype/edit")
    @PostMapping("/supplier/custom/customtype/edit")
    public CommonResult<String> edit(@RequestBody @Valid SupplierCustomTypeEditParam supplierCustomTypeEditParam) {
        supplierCustomTypeService.edit(supplierCustomTypeEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除客户类型
     *
     * @author Mr.wu
     * @date  2025/03/15 17:38
     */
    @Operation(summary = "删除客户类型")
    @CommonLog("删除客户类型")
    @SaCheckPermission("/supplier/custom/customtype/delete")
    @PostMapping("/supplier/custom/customtype/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<SupplierCustomTypeIdParam> supplierCustomTypeIdParamList) {
        supplierCustomTypeService.delete(supplierCustomTypeIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取客户类型详情
     *
     * @author Mr.wu
     * @date  2025/03/15 17:38
     */
    @Operation(summary = "获取客户类型详情")
    @SaCheckPermission("/supplier/custom/customtype/detail")
    @GetMapping("/supplier/custom/customtype/detail")
    public CommonResult<SupplierCustomType> detail(@Valid SupplierCustomTypeIdParam supplierCustomTypeIdParam) {
        return CommonResult.data(supplierCustomTypeService.detail(supplierCustomTypeIdParam));
    }

    /**
     * 获取会员列表
     *
     * @author Mr.wu
     * @date  2024/10/23 20:57
     */
    @Operation(summary = "获取客户类型信息列表")
    @SaCheckPermission("/supplier/custom/customtype/customTypeList")
    @GetMapping("/supplier/custom/customtype/customTypeList")
    public CommonResult<List<SupplierCustomType>> customTypeList() {
        return CommonResult.data(supplierCustomTypeService.customTypelist());
    }
}
